package executable.instance;

public class ClassWithReferenceArray {

    private ClassWithReferenceArray[] classWithReference;

    private int value;

    public ClassWithReferenceArray[] getClassWithReference() {
        return classWithReference;
    }

    public void setClassWithReference(ClassWithReferenceArray[] classWithReference) {
        this.classWithReference = classWithReference;
    }

    public int getValue() {
        return value;
    }

    public void setValue(int value) {
        this.value = value;
    }

    //////////static

    public static int useSimpleArray() {
        final ClassWithReferenceArray[] arrayClassWithReferenceArray = new ClassWithReferenceArray[5];
        final ClassWithReferenceArray classWithReferenceArray = new ClassWithReferenceArray();
        classWithReferenceArray.setValue(87);
        arrayClassWithReferenceArray[2] = classWithReferenceArray;
        return arrayClassWithReferenceArray[2].getValue();
    }


    public static int setAndReadSimple() {
        final ClassWithReferenceArray classWithReferenceArray1 = new ClassWithReferenceArray();
        classWithReferenceArray1.setValue(1);

        final ClassWithReferenceArray classWithReferenceArray2 = new ClassWithReferenceArray();
        classWithReferenceArray2.setValue(4);
        final ClassWithReferenceArray classWithReferenceArray3 = new ClassWithReferenceArray();
        classWithReferenceArray3.setValue(9);

        final ClassWithReferenceArray[] arrayClassWithReferenceArray = new ClassWithReferenceArray[5];
        arrayClassWithReferenceArray[1] = classWithReferenceArray1;
        arrayClassWithReferenceArray[2] = classWithReferenceArray2;
        arrayClassWithReferenceArray[3] = classWithReferenceArray3;

        classWithReferenceArray1.setClassWithReference(arrayClassWithReferenceArray);
        classWithReferenceArray2.setClassWithReference(arrayClassWithReferenceArray);

        final ClassWithReferenceArray classWithReferenceArray = classWithReferenceArray1.getClassWithReference()[2].getClassWithReference()[2];
        return classWithReferenceArray.getClassWithReference()[3].getValue();
    }

}
